package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.DishFlavor;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DishFlavorMapper {
    //通过dish_flavor表中的dish_id属性进行查找
    @Select("select * from dish_flavor where dish_id=#{dishId}")
    List<DishFlavor> findFlavorsByDishID(Long dishId);

    //修改口味
    Integer updateFlavors(DishFlavor dishFlavor);

    //根据id判断口味是否存在
    @Select("select * from dish_flavor where id=#{id}")
    DishFlavor findById(Integer id);

    //添加口味
    @Insert("insert into dish_flavor values (null,#{dishId},#{name},#{value},#{createTime},#{updateTime},#{createUser},#{updateUser},#{isDeleted})")
    Integer addFlavor(DishFlavor dishFlavor);

    //删除口味
    @Delete("delete from dish_flavor where id=#{id}")
    Integer delete(Long id);
    //添加口味
    Integer addDishFlavor(@Param("dishFlavors") List<DishFlavor> dishFlavors);
}
